package com.company.cloud.user.modules.api.response;

import com.company.cloud.common.tree.TreeEntityModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

@Getter
@Setter
public class PermissionModel implements TreeEntityModel {

    @ApiModelProperty(value = "权限编号")
    private String code;

    @ApiModelProperty(value = "权限分类（普通/菜单/按钮）")
    private String type;

    @ApiModelProperty(value = "权限名称")
    private String name;

    @ApiModelProperty(value = "菜单显示名称")
    private String showName;

    @ApiModelProperty(value = "菜单显示图标")
    private String icon;

    @ApiModelProperty(value = "菜单路由")
    private String url;

    @ApiModelProperty(value = "菜单状态")
    private String state;

    @ApiModelProperty(value = "菜单顺序")
    private Integer orders;

    @ApiModelProperty(value = "菜单显示平台")
    private String showPlatform;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "资源")
    private Set<String> resource;

    @ApiModelProperty(value = "上级权限编号")
    private String parentCode;

    @ApiModelProperty(value = "下级部门")
    private List<PermissionModel> children;

    @Override
    public void addChild(TreeEntityModel obj) {
        if (null == this.children) {
            this.children = new ArrayList<PermissionModel>();
        }
        if (null != obj) {
            if (obj instanceof PermissionModel) {
                this.children.add((PermissionModel) obj);
            }
        }

    }

}
